/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InfoAlarma.java
 *
 * Created on Dec 7, 2011, 3:12:13 PM
 */
package vista;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

/**
 *
 * @author LuisDeternoz
 */
public class InfoAlarma extends javax.swing.JFrame {

    /** Creates new form InfoAlarma */
    public InfoAlarma() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnAtrasAlarma1 = new javax.swing.JButton();
        btnInicio = new javax.swing.JButton();
        cboxAlarma = new javax.swing.JComboBox();
        btnIrAlarma1 = new javax.swing.JButton();
        Alarmas = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listAlarma = new javax.swing.JList();
        btnBuscarAlarma = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setMaximumSize(new java.awt.Dimension(700, 300));
        jPanel1.setPreferredSize(new java.awt.Dimension(700, 300));
        jPanel1.setRequestFocusEnabled(false);
        jPanel1.setVerifyInputWhenFocusTarget(false);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/digitelta4.3.jpg"))); // NOI18N
        jLabel1.setMaximumSize(new java.awt.Dimension(700, 114));
        jLabel1.setMinimumSize(new java.awt.Dimension(700, 114));
        jLabel1.setPreferredSize(new java.awt.Dimension(700, 114));
        jLabel1.setVerifyInputWhenFocusTarget(false);

        btnAtrasAlarma1.setFont(new java.awt.Font("Levenim MT", 1, 14)); // NOI18N
        btnAtrasAlarma1.setText("Atras");
        btnAtrasAlarma1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAtrasAlarma1ActionPerformed(evt);
            }
        });

        btnInicio.setFont(new java.awt.Font("Levenim MT", 1, 14)); // NOI18N
        btnInicio.setText("Salir");
        btnInicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInicioActionPerformed(evt);
            }
        });

        cboxAlarma.setFont(new java.awt.Font("Levenim MT", 1, 14)); // NOI18N
        cboxAlarma.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "8000", "8100", "8200" }));
        cboxAlarma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboxAlarmaActionPerformed(evt);
            }
        });

        btnIrAlarma1.setFont(new java.awt.Font("Levenim MT", 1, 14)); // NOI18N
        btnIrAlarma1.setText("Ir");
        btnIrAlarma1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIrAlarma1ActionPerformed(evt);
            }
        });

        Alarmas.setFont(new java.awt.Font("Levenim MT", 1, 14)); // NOI18N
        Alarmas.setText("Elija un Grupo de Alarmas");

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        jPanel2.setMaximumSize(new java.awt.Dimension(630, 147));
        jPanel2.setPreferredSize(new java.awt.Dimension(630, 147));
        jPanel2.setRequestFocusEnabled(false);
        jPanel2.setVerifyInputWhenFocusTarget(false);

        listAlarma.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(listAlarma);

        btnBuscarAlarma.setFont(new java.awt.Font("Levenim MT", 1, 14)); // NOI18N
        btnBuscarAlarma.setText("Buscar");
        btnBuscarAlarma.setToolTipText("");
        btnBuscarAlarma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarAlarmaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
                    .addComponent(btnBuscarAlarma, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscarAlarma, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 700, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(160, Short.MAX_VALUE)
                .addComponent(Alarmas)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cboxAlarma, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnIrAlarma1)
                .addGap(83, 83, 83)
                .addComponent(btnAtrasAlarma1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnInicio)
                .addGap(29, 29, 29))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(26, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(44, 44, 44))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnInicio)
                    .addComponent(btnAtrasAlarma1)
                    .addComponent(cboxAlarma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnIrAlarma1)
                    .addComponent(Alarmas, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 700, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel1.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnIrAlarma1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIrAlarma1ActionPerformed

    
    
    
}//GEN-LAST:event_btnIrAlarma1ActionPerformed

private void btnAtrasAlarma1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAtrasAlarma1ActionPerformed

    Inicio miventana = new Inicio();
    miventana.setVisible(true);
    this.setVisible(false);
}//GEN-LAST:event_btnAtrasAlarma1ActionPerformed

private void btnInicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInicioActionPerformed

    System.exit(0);
}//GEN-LAST:event_btnInicioActionPerformed

private void cboxAlarmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboxAlarmaActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cboxAlarmaActionPerformed

private void btnBuscarAlarmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarAlarmaActionPerformed

    Object[] seleccionados = listAlarma.getSelectedValues(); //Aca se obtiene cuantos Items tenemos en la lista
    int lim = seleccionados.length;
    String nombre;
    nombre = null;
    
        if (lim != 0)
        {
            for (int i=0; i <lim; i++)
            {
                nombre = seleccionados[i].toString(); //Aqui se obtiene el item seleccionado   
            }
            InfoAlarma2 miventana = new InfoAlarma2();
            miventana.setVisible(true);
            this.setVisible(false);
        }
        else
            JOptionPane.showMessageDialog(jPanel1, "Debes seleccionar una alarma");
   
}//GEN-LAST:event_btnBuscarAlarmaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InfoAlarma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InfoAlarma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InfoAlarma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InfoAlarma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InfoAlarma().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Alarmas;
    private javax.swing.JButton btnAtrasAlarma1;
    private javax.swing.JButton btnBuscarAlarma;
    private javax.swing.JButton btnInicio;
    private javax.swing.JButton btnIrAlarma1;
    private javax.swing.JComboBox cboxAlarma;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JList listAlarma;
    // End of variables declaration//GEN-END:variables
}
